package faq.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import faq.biz.FaqBiz;
import faq.entity.Faq;

@WebServlet("/index")
public class IndexServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
		FaqBiz faqBiz = ctx.getBean(FaqBiz.class);
		List<Faq> faqlist =faqBiz.getAll();
		req.setAttribute("faqlist", faqlist);
		req.getRequestDispatcher("index.jsp").forward(req, resp);
	}
}
